//
// Created by tjlhz on 2022/6/25.
//

#include "UserManager.h"

UserManager::UserManager() {
    CTeacher* teacher = new CTeacher();
    teacher->mTeacherId = 0;
    teacher->mName = "孔子";
    teacher->mPsw ="123456";
    this->mTeacherVec.push_back(teacher);
    CStudent * student = new CStudent();
    student->mStudentId = 0;
    student->mStudentNo="1";
    student->mName = "颜回";
    student->mPsw ="123456";
    this->mStudentVec.push_back(student);
}

CAdmin* UserManager::AdminLogin(int adminId, string psw) {
    //TODO:
    return NULL;
}

CTeacher* UserManager::TeacherLogin(int teacherId, string psw) {
    for(int i; i < mTeacherVec.size(); i++){
        CTeacher* teacher = mTeacherVec[i];
        if ((teacherId == teacher->mTeacherId)&&(psw == teacher->mPsw))
            return teacher;
    }
    return NULL;
}

CStudent * UserManager::StudentLogin(string studentNo, string psw) {
    for(int i; i < mStudentVec.size(); i++){
        CStudent *stu = mStudentVec[i];
        if ((studentNo == stu->mStudentNo)&&(psw == stu->mPsw))
            return stu;
    }
    return NULL;
}

bool UserManager::InsertAdmin(CAdmin admin) {
    //TODO:
    return false;
}

bool UserManager::EditStudent(CStudent student) {
    //TODO:
    return false;
}

CStudent UserManager::GetStudent(string studentId) {
    //TODO:
    return CStudent();
}

bool UserManager::DelStudent(CStudent student) {
    //TODO:
    return false;
}

vector<CStudent *> UserManager::GetClassStudent(string classId) {
    //TODO:
    return vector<CStudent *>();
}

UserManager::~UserManager() {
    for(int i; i < mStudentVec.size(); i++){
        delete mStudentVec[i];
    }
    for(int i; i < mTeacherVec.size(); i++){
        delete mTeacherVec[i];
    }
    for(int i; i < mAdminVec.size(); i++){
        delete mAdminVec[i];
    }
}
